/**
 * 详情对话框
 */
var GcgWsjdInfoDlg = {
    data: {
        gcgWsjdId: "",
        gcgProjectId: "",
        yaoma: "",
        mingcheng: "",
        dizhiSheng: "",
        dizhiShengView: "",
        dizhiShi: "",
        dizhiShiView: "",
        dizhiXianqu: "",
        dizhiXianquView: "",
        dizhiXiangxi: "",
        pinpai: "",
        guishu: "",
        mdTel: "",
        lxrName: "",
        lxrTel: "",
        jsTel: "",
        pinlei: "",
        mdYysj: "",
        isTcw: "",
        tcwPrice: "",
        renjunPrice: "",
        farenXingming: "",
        yhkName: "",
        yhkHao: "",
        isFapiao: "",
        isYouhui: "",
        farenSfzPic1: "",
        farenSfzPic2: "",
        farenSfzPic3: "",
        dzSfzPic1: "",
        dzSfzPic2: "",
        dzSfzPic3: "",
        yingyeZhizhao: "",
        shipinXkz: "",
        zfbShouquan: "",
        mentouPics: "",
        neijingPics: "",
        shStatus: "",
        createTime: "",
        createUser: "",
        updateTime: "",
        updateUser: "",
        gcgWsjdYinhangkaId: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    // /**
    //  * 检索区域
    //  */
    // var qyAjax = new $ax("/area/getAreaByType");
    // qyAjax.set("type", 2);
    // var qyResult = qyAjax.start();
    // $.each(qyResult, function (index, data) {
    //     $("#dizhiSheng").append("<option value='" + data.id + "'>" + data.simpleName + "</option>");
    // });
    // var qyAjax = new $ax("/area/getAreaByType");
    // qyAjax.set("type", 3);
    // var qyResult = qyAjax.start();
    // $.each(qyResult, function (index, data) {
    //     $("#dizhiShi").append("<option value='" + data.id + "'>" + data.simpleName + "</option>");
    // });
    // var qyAjax = new $ax("/area/getAreaByType");
    // qyAjax.set("type", 4);
    // var qyResult = qyAjax.start();
    // $.each(qyResult, function (index, data) {
    //     $("#dizhiXianqu").append("<option value='" + data.id + "'>" + data.simpleName + "</option>");
    // });
    // form.render('select');
    // form.on('select(dizhiSheng)', function (data) {
    //     var provinceId = data.value;
    //     isHasXianqu = false;
    //     if (provinceId == "") {
    //         $("#dizhiShi").html("");
    //         $("#dizhiShi").append("<option value=''>全部</option>");
    //         form.render('select');
    //     } else {
    //         var qyAjax = new $ax("/area/getAreaByPid");
    //         qyAjax.set("pid", provinceId);
    //         var qyResult = qyAjax.start();
    //         $("#dizhiShi").html("");
    //         $("#dizhiShi").append("<option value=''>全部</option>");
    //         $.each(qyResult, function (index, data) {
    //             $("#dizhiShi").append("<option value='" + data.id + "'>" + data.simpleName + "</option>");
    //         });
    //         form.render('select');
    //     }
    // });
    // var isHasXianqu = false;
    // form.on('select(dizhiShi)', function (data) {
    //     isHasXianqu = false;
    //     var cityId = data.value;
    //     if (cityId == "") {
    //         $("#dizhiXianqu").html("");
    //         $("#dizhiXianqu").append("<option value=''>全部</option>");
    //         form.render('select');
    //     } else {
    //         var qyAjax = new $ax("/area/getAreaByPid");
    //         qyAjax.set("pid", cityId);
    //         var qyResult = qyAjax.start();
    //         $("#dizhiXianqu").html("");
    //         $("#dizhiXianqu").append("<option value=''>全部</option>");
    //         $.each(qyResult, function (index, data) {
    //             $("#dizhiXianqu").append("<option value='" + data.id + "'>" + data.simpleName + "</option>");
    //             isHasXianqu = true;
    //         });
    //         form.render('select');
    //     }
    // });

    //YYJL
    var ajax1 = new $ax(Feng.ctxPath + "/project/selectYyjlList", function (data) {
        var sb;
        for(let i = 0; i < data.length; i++) {
            sb+='<option value="'+data[i].tel+'">' + data[i].yyjl + '</option>';
        }
        $("#yyjl").append(sb);
        form.render();
    }, function (data) {
        Feng.error(data.responseJSON.message);
    });
    ajax1.start();

    //dd
    var ajax2 = new $ax(Feng.ctxPath + "/project/selectDdList", function (data) {
        var sb;
        for(let i = 0; i < data.length; i++) {
            sb +='<option value="'+data[i].tel+'">' + data[i].dd + '</option>';
        }
        $("#dd").append(sb);
        form.render('select');
    }, function (data) {
        Feng.error(data.responseJSON.message);
    });
    ajax2.set("phone",$("#phone").val());
    ajax2.start();


    //DD
     form.on('select(yyjl)', function(data){
        var dd = data.value;
        $('#dd option').not('option:first').remove();
        if(data.value!=''){
            var ajax1 = new $ax(Feng.ctxPath + "/project/selectDdList", function (data) {
                var sb;
                for(let i = 0; i < data.length; i++) {
                    sb+='<option value="'+data[i].tel+'">' + data[i].dd + '</option>';
                }
                $("#dd").append(sb);
                form.render();
            }, function (data) {
                Feng.error(data.responseJSON.message);
            });
            ajax1.set("phone",data.value);
            ajax1.start();
        }
    });


    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/wsjd/detail?gcgWsjdId=" + Feng.getUrlParam("gcgWsjdId"));
    var result = ajax.start();
    form.val('gcgWsjdForm', result.data);



    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/wsjd/editItem", function (data) {
            Feng.success("更新成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

});